package com.centriole.service.workflow.service.impl;

import com.centriole.service.workflow.dao.ProParameterMapper;
import com.centriole.service.workflow.entity.ProParameter;
import com.centriole.service.workflow.enums.StateType;
import com.centriole.service.workflow.service.ProParameterService;
import com.centriole.service.workflow.util.CommonUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class ProParameterServiceImpl implements ProParameterService {

	@Resource
	private ProParameterMapper proParameterMapper;
	public void insertParameter(ProParameter proParameter) {
		// check
		
		if(CommonUtil.isEmpty(proParameter.getId())){
			proParameter.setId(CommonUtil.getUuid());
			proParameter.setState(StateType.NORMAL.statusCode());
			proParameter.setCreateDate(new Date());
			proParameterMapper.insert(proParameter);
		}else{
			proParameterMapper.update(proParameter);
		}
	}

	public void logicDeleteByProcessId(String id) {
		proParameterMapper.logicDelete(id);
	}

	public void deleteByProcessId(String processId) {
		proParameterMapper.deleteByProcessId(processId);
	}

	public List<ProParameter> selectByProcessId(String processId) {
		List<ProParameter> list = proParameterMapper.selectByProcessId(processId);
		return list;
	}

	public ProParameter selectById(String id) {
		ProParameter p = proParameterMapper.selectById(id);
		return p;
	}
	@Override
	public List<ProParameter> select() {
		List<ProParameter> list = proParameterMapper.select();
		return list;
	}
}
